<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class IndexController extends Controller
{
    //默认首页
    public function index()
    {
        //分配商品标签分类
        $tag = DB::table('tag')->get();
        //广告图片展示
        $ad = DB::table('img')
            ->where('img.status','=',1)
            ->leftJoin('goods','img.goods_id','=','goods.goods_id')
            ->where(['goods.status'=>1])
            ->get();
        //标签下热门商品的展示
        $goods = DB::table('goods')
            ->where(['hot'=>1,'goods.status'=>1])
            ->leftJoin('img','goods.goods_id','=','img.goods_id')
            ->get();
        //分配session信息到主页模板
        $user_info= session('sign_user_info');
       return view('Home/Index/index')->with('tag',$tag)->with('ad',$ad)->with('goods',$goods)->with('user_info',$user_info);
    }

}
